/*
 * @Author: wusd
 * @Date: 2022-06-15 09:39:58
 * @LastEditors: wusd
 * @LastEditTime: 2022-06-15 11:22:46
 * @Description:
 *
 */
import Vue from 'vue'
import Vuex from 'vuex'
import tab from './tab'
import user from './user'
import stroage from '@/untils/stroage'
import { AnyObj } from 'types/common'
Vue.use(Vuex)
export default new Vuex.Store({
  modules: {
    tab,
    user
  },
  mutations: {
    setStore(state: AnyObj) {
      state.user.token = stroage.get('token')
      state.user.userInfo = stroage.get('userInfo')
      if (!stroage.get('menue') || stroage.get('menue') === 'undefined') {
        state.tab.menue = []
      } else {
        state.tab.menue = stroage.get('menue')
      }
    },
    clearStorge(state) {
      stroage.remove('token')
      stroage.remove('userInfo')
      stroage.remove('menue')
      state.user.token = ''
      state.user.userInfo = {}
      state.tab.menue = []
    }
  }
})
